﻿
using Prism.Events;
using Prism.Ioc;
using Prism.Mvvm;
using Prism.Regions;
using WPFNote.Utilities.Extensions;

namespace WPFNote.ViewModels {
    public class NavigationViewModel : BindableBase, INavigationAware {
        private readonly IContainerProvider _containerProvider;
        protected readonly IEventAggregator Aggregator;

        protected NavigationViewModel(IContainerProvider containerProvider)
        {
            this._containerProvider = containerProvider;
            Aggregator = containerProvider.Resolve<IEventAggregator>();
        }

        public virtual bool IsNavigationTarget(NavigationContext navigationContext)
        {
            return true;
        }

        public virtual void OnNavigatedFrom(NavigationContext navigationContext)
        {

        }

        public virtual void OnNavigatedTo(NavigationContext navigationContext)
        {

        }

        protected void UpdateLoading(bool isOpen)
        {
            Aggregator.UpdateLoading(new Utilities.Events.UpdateModel()
            {
                IsOpen = isOpen
            });
        }
    }
}